#include<bits/stdc++.h>
using namespace std;
int main()
{
    freopen("color.in","r",stdin);
    freopen("color.out","w",stdout);
    int T;
    cin >> T;
    for(int q = 0;q < T;q++)
    {
        int l[1000000];
        int n;
        cin >> n;
        for(int i = 0;i < n;i++)
        {
            cin >> l[i];
        } 
        int a = l[0],b= l[2],ans = 0;
        for(int i = 0;i < n-2;i++)
        {
            if(a == b)
            {
                ans = a+ans;
            }
            a = l[i+1];
            b = l[i+3];
        }
        cout << ans;
    }
    return 0;
}